﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminPanel/AdminSite.Master" AutoEventWireup="true"
CodeBehind="Customers.aspx.cs" Inherits="FastTrackCabService.AdminPanel.Customers" %>
<%@ Import Namespace="BusinessLogicLayer" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../Style/Supervisors.css" rel="stylesheet" type="text/css"/>
    <script src="../Scripts/jquery.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.maskedinput.min.js" type="text/javascript"></script>
    <script src="../Scripts/masked_telephone.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <table style="margin: 1.5em auto;">
        <tr>
            <td>
                <div class="searchBox">
                    <asp:TextBox ID="tbTelephone" runat="server" placeholder="Search by telephone" CssClass="myTextBox">
                    </asp:TextBox>
                    <asp:ImageButton ID="ibtnSearch" runat="server" OnClick="ibtnSearch_OnClick" ImageUrl="~/Images/magnifying_glass_icon.png">
                    </asp:ImageButton>
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <asp:GridView ID="gvCustomers" CssClass="supervisors" runat="server" CellPadding="4"
                              ForeColor="#333333" GridLines="None" AllowPaging="True" AutoGenerateColumns="False"
                              OnPageIndexChanging="gvCustomers_OnPageIndexChanging">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
                    <Columns>
                        <asp:BoundField DataField="CustomerId" HeaderText="Id"/>
                        <asp:TemplateField HeaderText="Name">
                            <ItemTemplate>
                                <%# CustomerBLL.GetCustomerName(Convert.ToInt32(Eval("CustomerId"))) %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="TelephoneNo" HeaderText="Telephone"/>
                        <asp:BoundField DataField="Type" HeaderText="Customer Type"/>
                        <asp:TemplateField HeaderText="Subsidiary">
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# CityBLL.GetCityById(SubsidiaryBLL.GetCityIdBySubsidiaryId(Convert.ToByte(Eval("SubsidiaryId")))).Name %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Action">
                            <ItemTemplate>
                                <asp:ImageButton ID="ibView" ToolTip="View full details" Width="30" PostBackUrl='<%# "CustomerFullView.aspx?cusId=" + Eval("CustomerId") %>'
                                                 ImageUrl="../Images/view-black.png" runat="server">
                                </asp:ImageButton>
                                <asp:ImageButton ID="ibBan" Visible='<%# !UserBLL.IsBannedUser(Eval("Username").ToString()) %>'
                                                 PostBackUrl='<%# "?username=" + Eval("Username") %>' OnClick="ibBan_OnClick"
                                                 ToolTip="Ban this customer" OnClientClick=" if (!confirm('Are you sure do you want to ban this customer?')) return false; "
                                                 ImageUrl="../Images/lock.png" runat="server"/>
                                <asp:ImageButton ID="ibUnban" Visible='<%# UserBLL.IsBannedUser(Eval("Username").ToString()) %>'
                                                 ToolTip="Unban this customer" PostBackUrl='<%# "?username=" + Eval("Username") %>'
                                                 OnClick="ibUnban_OnClick" ImageUrl="../Images/unlock.png" runat="server"/>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataRowStyle CssClass="emptyDataRow"></EmptyDataRowStyle>
                    <EmptyDataTemplate>
                        <table class="supervisors" id="ContentPlaceHolder1_gvSupervisors" style="border-collapse: collapse; color: #333333; width: 600px;">
                            <tr style="background-color: #5D7B9D; color: White; font-weight: bold;">
                                <th scope="col">
                                    Id
                                </th>
                                <th scope="col">
                                    First Name
                                </th>
                                <th scope="col">
                                    Telephone
                                </th>
                                <th scope="col">
                                    Customer Type
                                </th>
                                <th scope="col">
                                    Subsidiary
                                </th>
                                <th scope="col">
                                    Action
                                </th>
                            </tr>
                            <tr style="background-color: #F7F6F3; color: #333333;">
                                <td colspan="6" style="padding: 0.5em;">
                                    NO CUSTOMER AVAILABLE
                                </td>
                            </tr>
                        </table>
                    </EmptyDataTemplate>
                    <EditRowStyle BackColor="#999999"/>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333"/>
                    <SortedAscendingCellStyle BackColor="#E9E7E2"/>
                    <SortedAscendingHeaderStyle BackColor="#506C8C"/>
                    <SortedDescendingCellStyle BackColor="#FFFDF8"/>
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE"/>
                </asp:GridView>
            </td>
        </tr>
    </table>
    <asp:ImageButton ID="ibAdd" ToolTip="Register a customer" ImageUrl="../Images/add-yellow.png"
                     PostBackUrl="CustomerRegistrationForm.aspx" CssClass="addButton" runat="server"/>
</asp:Content>